<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <t:base type="jquery,easyui,tools,DatePicker,ckeditor"></t:base>
    <link rel="stylesheet" href="${webRoot}/plug-in/lhgDialog/skins/blue.css"/>
    <link rel="stylesheet" href="${webRoot}/plug-in/lhgDialog/skins/default.css"/>
    <script type="text/javascript" src="${webRoot}/plug-in/ajaxfileupload/ajaxfileupload.js"></script>
    <script type="text/javascript" charset="utf-8"
            src="${webRoot}/plug-in/ueditor1_4_3-utf8-jsp/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8"
            src="${webRoot}/plug-in/ueditor1_4_3-utf8-jsp/ueditor.all.min.js"></script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8"
            src="${webRoot}/plug-in/ueditor1_4_3-utf8-jsp/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript" charset="utf-8" src="${webRoot}/plug-in/QQgeo/geo.js"></script>
    <script type="text/javascript" charset="utf-8" src="${webRoot}/plug-in/My97DatePicker/WdatePicker.js"></script>
</head>
<body scroll="no">
<t:formvalid formid="addformobj" dialog="true" usePlugin="password" layout="table"
             action="qqOptionController.do?saveorupdate" beforeSubmit="checkName">
    <%--选项id--%>
    <input name="id" type="hidden" value="${entity.id}">
    <%--问题id--%>
    <input name="questEntity.id" type="hidden" value="${entity.questEntity.id}"/>
    <%--量表id--%>
    <input type="hidden" value="${entity.questEntity.questEntity.id}"/>

    <div class="new_table_list">
        <table cellpadding="0" cellspacing="0" class="formtable">
            <tbody>
            <tr>
                <th colspan="2">选项</th>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        选项名称:
                    </label>
                </td>
                <td class="txt_left value">
                    <input class="inputxt" style="width: 250px;" id="name" name="name" value="${entity.name}"
                           datatype="*"
                           maxlength="128">
                    <span class="Validform_checktip"></span>
                </td>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        选项标识:
                    </label>
                </td>
                <td class="txt_left value">
                    <input class="inputxt" style="width: 250px;" name="optionIdentity" value="${entity.optionIdentity}"
                           datatype="*"
                           maxlength="128">
                    <span class="Validform_checktip"></span>
                </td>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        分数:
                    </label>
                </td>
                <td class="txt_left value">
                    <input class="inputxt" style="width: 250px;" id="score" name="score" value="${entity.score}"
                           datatype="num"
                           maxlength="128">
                    <span class="Validform_checktip"></span>
                </td>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        回答方式:
                    </label>
                </td>
                <td class="txt_left value">
                    <t:dictSelect id="answerType" field="replyType" typeGroupCode="answerType"
                                  defaultVal="${entity.replyType}" hasLabel="false"></t:dictSelect>
                </td>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        选择此项后不答题:
                    </label>
                </td>
                <td class="txt_left value">
                    <input type="hidden" id="qqId" name="noanswer"
                           value="${entity.noanswer}">
                    <textarea style="width: 250px;height: 100px;" readonly="readonly"
                              id="showName2">${entity.noanswer}</textarea>
                    <t:choose getParamsFun="f_getStaffParam()" name="qqSelectNoanswerList" hiddenName="qqId" hiddenid="id"
                              url="quesquesController.do?selectList_noanswer"
                              icon="icon-search" title="问题关联" inputTextname="showName2"
                              textname="id" isclear="false" width="650px" height="450px"
                            ></t:choose>
                    <span class="Validform_checktip"></span>
                </td>
            </tr>

        </table>
    </div>
</t:formvalid>
<script type="text/javascript">
    $(function () {
        $("#answerType").children().first().remove();
    });

    function checkName() {
        var quesId = "${entity.questEntity.id}";//量表id
        var id = "${entity.id}";//问题id
        var name = $("#name").val();//问题
        var url = "qqOptionController.do?checkName";
        var flag = false;
        $.ajax({
            url: url,
            async: false, // 注意此处需要同步，因为返回完数据后，下面才能让结果的第一条selected
            type: "GET",
            dataType: "json",
            data: {quesId: quesId, id: id, name: name},
            success: function (data) {
                if (data.code == 1) {
                    tip(data.msg);
                } else {
                    flag = true;
                }
            }
        });
        return flag;
    }
    function f_getStaffParam() {
        var qqid = "${entity.questEntity.id}";//问题id
        var qsid ="${entity.questEntity.questEntity.id}";//量表id
        var qqids = $("#qqId").val();
        return "&qsid="+qsid+"&qqid=" + qqid+"&qqids="+qqids;
    }

</script>
</body>

</html>